from workflow.novel_workflow import create_novel_workflow

def main():
    print("📚 小说拆解仿写 Agent 启动")
    print("=" * 30)
    
    # 这里输入你的小说路径，支持相对路径
    novel_path = input("请输入小说文件路径 (例如 workspace/story.txt): ").strip()
    
    if not novel_path:
        print("❌ 路径不能为空")
        return
        
    workflow = create_novel_workflow()
    
    print(f"\n🚀 开始处理: {novel_path}")
    
    try:
        # 运行工作流
        # 初始状态只需提供 novel_path
        # 设置 recursion_limit 为 10000 以支持长篇小说分析
        workflow.invoke({
            "novel_path": novel_path,
            "output_dir": "",      # 将由 split_node 填充
            "chapter_files": [],   # 将由 split_node 填充
            "current_index": 0,
            "summaries": []
        }, config={"recursion_limit": 10000})
        
        print("\n✅ 全部完成！请查看生成的拆解档案文件夹。")
        
    except Exception as e:
        print(f"\n❌ 发生错误: {e}")

if __name__ == "__main__":
    main()
